local Tichun = fk.CreateSkill {
    name = "Tichun",
    anim_type = "defensive",
}

Fk:loadTranslationTable{
    ["Tichun"] = "提纯",
    [":Tichun"] = "当你受到【杀】或者伤害锦囊牌的伤害时，你令一名其他角色选择是否摸一张牌并替你承受此伤害。",
    ["#TichunTarget"] = "提纯：请选择一名其他角色，其可能会替你承受此伤害。",
    ["#TichunAsk"] = "提纯：是否摸一张牌并替 %src 承受此伤害？",


  }
  

  Tichun:addEffect(fk.DamageInflicted, {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(Tichun.name) and target == player and data.card then
      return data.card.trueName == "slash" or (data.card.type == Card.TypeTrick and data.card.is_damage_card)
    end
  end,
  
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = room:askToChoosePlayers(player, {
        targets = room:getOtherPlayers(player),
        min_num = 1,
        max_num = 1,
        prompt = "#TichunTarget",
        skill_name = Tichun.name,
        cancelable = true,
      })
      if #targets > 0 then
        event:setCostData(self, {target = targets[1]})
        return true
      end
   
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target = event:getCostData(self).target
    if player.room:askToSkillInvoke(target, {
        skill_name = Tichun.name,
        prompt = "#TichunAsk:".. player.id,
    }) then
        room:drawCards(target, 1, Tichun.name)
        room:damage({
            from = data.from,
            to = target,
            damage = data.damage,
            skillName = Tichun.name
        })
        data:preventDamage()
    end
  end
})


return Tichun 